﻿using UnityEngine;
using System.Collections;

public class LoadLevel : MonoBehaviour {
	private GameManager manager;
	private int temp;
	
    [SerializeField]
    private AudioClip soundClip;
	private void Start(){
		manager=GameManager.getInstance();
		//temp=int.Parse( btn_level.name.Remove(0,9));
	}
    public void level()
	{
        if (manager.Sound)
        { PlaySound(); }
        manager.Level.NumberofLevel=temp;
        manager.Level.NumberofLevel = manager.currentLevel;

        StartCoroutine(loadNextScene());
		//new Invoker(new Play(4)).Execute();  
		manager.IsShow=false;
    }

    private IEnumerator loadNextScene()
    {
        yield return new WaitForSeconds(0.5f);
        new Invoker(new Play(4)).Execute();
    }
    void PlaySound()
    {
        audio.clip = soundClip;
        audio.Play();
    }
}
